package UI;

import facecat.topin.btn.*;
import facecat.topin.core.*;
import facecat.topin.xml.*;
import org.w3c.dom.Node;

public class UIXmlEx extends FCUIXml {
    public UIXmlEx()
    {
    }

    private double m_scaleFactor = 1;

    /*
     * 获取或设置缩放因子
     */
    public double getScaleFactor()
    {
        return m_scaleFactor;
    }

    /*
     * 设置缩放因子
     */
    public void setScaleFactor(double value)
    {
        m_scaleFactor = value;
        if (getNative() != null)
        {
            getNative().getPaint().setScaleFactor(m_scaleFactor, m_scaleFactor);
        }
    }
    
    /** 
        创建视图
        @param node 节点
        @param type 类型
        @return 视图
    */
    @Override
    public FCView createView(Node node, String type)
    {
        if(type.equals("mychart")){
            return new MyChart();
        }else if(type.equals("latestdiv")){
            return new LatestDiv();
        }else if(type.equals("securitylist")){
            return new SecurityList();
        }else{
                return super.createView(node, type);
        }
    }

    /*
     * 重置缩放尺寸
     */
    public void resetScaleSize(FCSize clientSize)
    {
        FCNative inative = getNative();
        if (inative != null)
        {
            FCHost host = inative.getHost();
            FCSize nativeSize = inative.getSize();
            inative.setScaleSize(new FCSize((int)(clientSize.cx * m_scaleFactor), (int)(clientSize.cy * m_scaleFactor)));
            inative.update();
        }
    }
}
